<?php
class ControllerSoftDoctor extends Controller
{
	function index()
	{	
		$this->getList();
		$this->id='content';
		$this->template='soft/doctor.tpl';
		$this->layout='layout/center';
		$this->render(); 
	}
	
	function getList()
	{
		$this->load->model("core/user");
		$where = " AND usertypeid = 'doctor' ";
		$this->data['doctors'] = $this->model_core_user->getList($where);
	}
	
	public function save()
	{
		$this->load->model("core/user");
		$data = $this->request->post;
		$data['usertypeid'] = "doctor";
		if($data['userid']=="")
			$this->model_core_user->insertUser($data);
		else
			$this->model_core_user->updateuser($data);
		$this->data['output'] = 'true';
		$this->id='category';
		$this->template='common/output.tpl';
		$this->render();
	}
	
	public function getDoctor()
	{
		$this->load->model("core/user");
		$userid = $this->request->get['userid'];
		$user=$this->model_core_user->getItem($userid);
		$this->data['output'] = json_encode(array('user' => $user));
		$this->id='post';
		$this->template="common/output.tpl";
		$this->render();
	}
	
	public function removeDoctor()
	{
		$userid = $this->request->get['userid'];
		//Ktra toan ven du lieu
		$this->load->model("addon/order");
		$this->load->model("core/user");
		$this->model_core_user->deleteuser($userid);
		$this->data['output'] = "true";
		$this->id='post';
		$this->template="common/output.tpl";
		$this->render();
	}
}
?>